package com.milling.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.milling.common.annotation.Log;
import com.milling.common.core.controller.BaseController;
import com.milling.common.core.domain.AjaxResult;
import com.milling.common.enums.BusinessType;
import com.milling.business.domain.WmsShelfInfo;
import com.milling.business.service.IWmsShelfInfoService;
import com.milling.common.utils.poi.ExcelUtil;
import com.milling.common.core.page.TableDataInfo;

/**
 * 货架设置Controller
 *
 * @author X
 * @date 2025-01-22
 */
@RestController
@RequestMapping("/business/shelfinfo")
public class WmsShelfInfoController extends BaseController
{
    @Autowired
    private IWmsShelfInfoService wmsShelfInfoService;

    /**
     * 查询货架设置列表
     */
    @PreAuthorize("@ss.hasPermi('business:shelfinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsShelfInfo wmsShelfInfo)
    {
        startPage();
        List<WmsShelfInfo> list = wmsShelfInfoService.selectWmsShelfInfoList(wmsShelfInfo);
        return getDataTable(list);
    }

    /**
     * 导出货架设置列表
     */
    @PreAuthorize("@ss.hasPermi('business:shelfinfo:export')")
    @Log(title = "货架设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsShelfInfo wmsShelfInfo)
    {
        List<WmsShelfInfo> list = wmsShelfInfoService.selectWmsShelfInfoList(wmsShelfInfo);
        ExcelUtil<WmsShelfInfo> util = new ExcelUtil<WmsShelfInfo>(WmsShelfInfo.class);
        util.exportExcel(response, list, "货架设置数据");
    }

    /**
     * 获取货架设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:shelfinfo:query')")
    @GetMapping(value = "/{shelfId}")
    public AjaxResult getInfo(@PathVariable("shelfId") Long shelfId)
    {
        return success(wmsShelfInfoService.selectWmsShelfInfoByShelfId(shelfId));
    }

    /**
     * 新增货架设置
     */
    @PreAuthorize("@ss.hasPermi('business:shelfinfo:add')")
    @Log(title = "货架设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsShelfInfo wmsShelfInfo)
    {
        return toAjax(wmsShelfInfoService.insertWmsShelfInfo(wmsShelfInfo));
    }

    /**
     * 修改货架设置
     */
    @PreAuthorize("@ss.hasPermi('business:shelfinfo:edit')")
    @Log(title = "货架设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsShelfInfo wmsShelfInfo)
    {
        return toAjax(wmsShelfInfoService.updateWmsShelfInfo(wmsShelfInfo));
    }

    /**
     * 删除货架设置
     */
    @PreAuthorize("@ss.hasPermi('business:shelfinfo:remove')")
    @Log(title = "货架设置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{shelfIds}")
    public AjaxResult remove(@PathVariable Long[] shelfIds)
    {
        return toAjax(wmsShelfInfoService.deleteWmsShelfInfoByShelfIds(shelfIds));
    }
}
